package cn.wellwan.commons;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by yiyongyao on 2018/1/18.
 *  公共物流模块统一异常处理
 */
@ControllerAdvice
public class WellwanExceptionHandler {

    private final Logger LOG = LoggerFactory.getLogger(WellwanExceptionHandler.class);

    /**
     * 业务异常处理
     *
     * @param exception
     * @return
     */
    @ExceptionHandler(value = WellwanBusinessException.class)
    @ResponseBody
    public Result handle(WellwanBusinessException exception) {
        LOG.error("====================> 公共物流模块统一异常处理:{}", exception.getMessage());
        return Result.fail(exception.getMessage());
    }
}
